package com.morn.fanfou.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.morn.fanfou.AboutActivity;
import com.morn.fanfou.ConfigActivity;
import com.morn.fanfou.R;
import com.morn.fanfou.UpdateActivity;
import com.morn.fanfou.UserViewActivity;

public class CopyOfMoreFragment extends Fragment implements OnClickListener {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.more, container, false);
		TextView titleText = (TextView) v.findViewById(R.id.header_title_text);
		titleText.setText(R.string.header_title_more);

		ImageView leftImage = (ImageView) v
				.findViewById(R.id.header_image_right);
		leftImage.setVisibility(View.GONE);

		ImageView rightImage = (ImageView) v
				.findViewById(R.id.header_image_left);
		rightImage.setVisibility(View.GONE);

		View configView = v.findViewById(R.id.more_config);
		configView.setOnClickListener(this);

		View authorView = v.findViewById(R.id.more_author);
		authorView.setOnClickListener(this);

		View suggestionView = v.findViewById(R.id.more_suggestion);
		suggestionView.setOnClickListener(this);

		View aboutView = v.findViewById(R.id.more_about);
		aboutView.setOnClickListener(this);

		return v;
	}

	@Override
	public void onClick(View v) {
		int viewId = v.getId();
		Intent intent = null;
		if (viewId == R.id.more_config) {
			intent = new Intent(this.getActivity(), ConfigActivity.class);
		} else if (viewId == R.id.more_author) {
			intent = new Intent(this.getActivity(), UserViewActivity.class);
			intent.putExtra("userId", "imorn");
		} else if (viewId == R.id.more_suggestion) {
			// TODO
			intent = new Intent(this.getActivity(), UpdateActivity.class);
			intent.putExtra("userName", "imorn");
		} else if (viewId == R.id.more_about) {
			intent = new Intent(this.getActivity(), AboutActivity.class);
		}
		this.getActivity().startActivity(intent);

	}
}
